package com.anolesoft.amljmes.test.fenguangyingdu.mapper;

import com.anolesoft.amljmes.test.fenguangyingdu.entity.FenguangYingduRecordDO;
import org.apache.ibatis.annotations.*;
import org.apache.ibatis.type.JdbcType;
import org.apache.ibatis.type.LocalDateTimeTypeHandler;

/**
 * @author zhj
 * @date 2021/12/22 10:32
 */
@Mapper
public interface FenguangYingduRecordMapper {
    @Results(id = "FenguangYingduRecordResultMap", value = {
            @Result(id = true, column = "objuid", property = "objuid", jdbcType = JdbcType.VARCHAR),
            @Result(column = "jianbiaotiaoma", property = "jianbiaotiaoma", jdbcType = JdbcType.VARCHAR),
            @Result(column = "jixing", property = "jixing", jdbcType = JdbcType.VARCHAR),
            @Result(column = "tuhao", property = "tuhao", jdbcType = JdbcType.VARCHAR),
            @Result(column = "cailiaopaihao", property = "cailiaopaihao", jdbcType = JdbcType.VARCHAR),
            @Result(column = "songjiandanwei", property = "songjiandanwei", jdbcType = JdbcType.VARCHAR),
            @Result(column = "lupihao", property = "lupihao", jdbcType = JdbcType.VARCHAR),
            @Result(column = "jianshu", property = "jianshu", jdbcType = JdbcType.INTEGER),
            @Result(column = "songjiangongxuhao", property = "songjiangongxuhao", jdbcType = JdbcType.VARCHAR),
            @Result(column = "songjiangongxumingcheng", property = "songjiangongxumingcheng", jdbcType = JdbcType.VARCHAR),
            @Result(column = "fenguangshuliang", property = "fenguangshuliang", jdbcType = JdbcType.INTEGER),
            @Result(column = "yingdushuliang", property = "yingdushuliang", jdbcType = JdbcType.INTEGER),
            @Result(column = "yingdushicezhi", property = "yingdushicezhi", jdbcType = JdbcType.VARCHAR),
            @Result(column = "jianyan", property = "jianyan", jdbcType = JdbcType.VARCHAR),
            @Result(column = "beizhu", property = "beizhu", jdbcType = JdbcType.VARCHAR),
            @Result(column = "state", property = "state", jdbcType = JdbcType.INTEGER),
            @Result(column = "create_user", property = "createUser", jdbcType = JdbcType.VARCHAR),
            @Result(column = "create_date", property = "createDate", typeHandler = LocalDateTimeTypeHandler.class),
            @Result(column = "shenpiren", property = "shenpiren", jdbcType = JdbcType.VARCHAR),
            @Result(column = "shenpishijian", property = "shenpishijian", typeHandler = LocalDateTimeTypeHandler.class),
            @Result(column = "zhizaojilutiaoma", property = "zhizaojilutiaoma", jdbcType = JdbcType.VARCHAR),
            @Result(column = "zhizaojiluid", property = "zhizaojiluid", jdbcType = JdbcType.VARCHAR),
            @Result(column = "shenqingren", property = "shenqingren", jdbcType = JdbcType.VARCHAR),
            @Result(column = "shenqingshijian", property = "shenqingshijian", typeHandler = LocalDateTimeTypeHandler.class),

    })
    @Select("SELECT\n" +
            "a.OBJUID,\n" +
            "a.JIANBIAOTIAOMA,\n" +
            "a.TUHAO,\n" +
            "a.JIXING,\n" +
            "a.CAILIAOPAIHAO,\n" +
            "a.SONGJIANDANWEI,\n" +
            "a.LUPIHAO,\n" +
            "a.JIANSHU,\n" +
            "a.SONGJIANGONGXUHAO,\n" +
            "a.SONGJIANGONGXUMINGCHENG,\n" +
            "a.FENGUANGSHULIANG,\n" +
            "a.YINGDUSHULIANG,\n" +
            "a.YINGDUSHICEZHI,\n" +
            "a.JIANYAN,\n" +
            "a.BEIZHU,\n" +
            "a.STATE,\n" +
            "a.CREATE_USER,\n" +
            "a.CREATE_DATE,\n" +
            "a.MODIFY_USER,\n" +
            "a.MODIFY_DATE,\n" +
            "a.SHENPIREN,\n" +
            "a.SHENPISHIJIAN,\n" +
            "a.ZHIZAOJILUTIAOMA,\n" +
            "a.ZHIZAOJILUID,\n"+
            "a.SHENQINGREN,\n"+
            "a.SHENQINGSHIJIAN\n"+
            "FROM \n" +
            "CHECK_FENGUANGYINGDU_RECORD a \n" +
            "where a.objuid = #{id,jdbcType=VARCHAR}" )
    FenguangYingduRecordDO selectOneById(@Param("id")String id);

    @Insert("insert into CHECK_FENGUANGYINGDU_RECORD (\n" +
            "OBJUID,\n" +
            "JIANBIAOTIAOMA,\n" +
            "TUHAO,\n" +
            "JIXING,\n" +
            "CAILIAOPAIHAO,\n" +
            "SONGJIANDANWEI,\n" +
            "LUPIHAO,\n" +
            "JIANSHU,\n" +
            "SONGJIANGONGXUHAO,\n" +
            "SONGJIANGONGXUMINGCHENG,\n" +
            "FENGUANGSHULIANG,\n" +
            "YINGDUSHULIANG,\n" +
            "YINGDUSHICEZHI,\n" +
            "JIANYAN,\n" +
            "BEIZHU,\n" +
            "STATE,\n" +
            "CREATE_USER,\n" +
            "CREATE_DATE,\n" +
//        "MODIFY_USER,\n" +
//        "MODIFY_DATE,\n" +
//        "SHENPIREN,\n" +
//        "SHENPISHIJIAN,\n" +
            "ZHIZAOJILUTIAOMA,\n" +
            "ZHIZAOJILUID \n" +
            ") values (\n" +
            "#{objuid,jdbcType=VARCHAR},\n" +
            "concat(#{jianbiaotiaoma,jdbcType=VARCHAR},LPAD(seq_fenguangjianyan.nextval,10,0)),\n" +
            "#{tuhao,jdbcType=VARCHAR},\n" +
            "#{jixing,jdbcType=VARCHAR},\n" +
            "#{cailiaopaihao,jdbcType=VARCHAR},\n" +
            "#{songjiandanwei,jdbcType=VARCHAR},\n" +
            "#{lupihao,jdbcType=VARCHAR},\n" +
            "#{jianshu,jdbcType=INTEGER},\n" +
            "#{songjiangongxuhao,jdbcType=VARCHAR},\n" +
            "#{songjiangongxumingcheng,jdbcType=VARCHAR},\n" +
            "#{fenguangshuliang,jdbcType=INTEGER},\n" +
            "#{yingdushuliang,jdbcType=INTEGER},\n" +
            "#{yingdushicezhi,jdbcType=VARCHAR},\n" +
            "#{jianyan,jdbcType=VARCHAR},\n" +
            "#{beizhu,jdbcType=VARCHAR},\n" +
            "#{state,jdbcType=INTEGER},\n" +
            "#{createUser,jdbcType=VARCHAR},\n" +
            "sysdate,\n" +
//        "#{modifyUser,jdbcType=VARCHAR},\n" +
//        "#{modifyDate,jdbcType=DATE},\n" +
//        "#{shenpiren,jdbcType=VARCHAR},\n" +
//        "#{shenpishijian,jdbcType=DATE},\n" +
            "#{zhizaojilutiaoma,jdbcType=VARCHAR},\n" +
            "#{zhizaojiluid,jdbcType=VARCHAR}\n" +
            ")")
    int insert(FenguangYingduRecordDO fenguangYingduRecordDO);

    @Delete("delete from  CHECK_FENGUANGYINGDU_RECORD where objuid = #{id,jdbcType=VARCHAR}")
    int delete(@Param("id") String id);

    @Update("update CHECK_FENGUANGYINGDU_RECORD set " +
            "state = #{state,jdbcType=INTEGER}," +
            "SHENQINGREN = #{shenqingren,jdbcType=VARCHAR}," +
            "shenqingshijian=sysdate," +
            "MODIFY_USER=#{shenqingren,jdbcType=VARCHAR}," +
            "MODIFY_DATE=sysdate " +
            "where objuid = #{id,jdbcType=VARCHAR}")
    int updateStateForApply(@Param("state")Integer state, @Param("shenqingren")String shenqingren,@Param("id")String id);

    @Update("update CHECK_FENGUANGYINGDU_RECORD set " +
            "state = #{state,jdbcType=INTEGER}," +
            "shenpiren = #{shenpiren,jdbcType=VARCHAR}," +
            "shenpishijian=sysdate," +
            "MODIFY_USER=#{shenpiren,jdbcType=VARCHAR}," +
            "MODIFY_DATE=sysdate " +
            "where objuid = #{id,jdbcType=VARCHAR}")
    int updateStateForAgree(@Param("state")Integer state, @Param("shenpiren")String shenqingren,@Param("id")String id);

    @Update("update CHECK_FENGUANGYINGDU_RECORD set \n" +
            "FENGUANGSHULIANG = #{fenguangshuliang,jdbcType=INTEGER},\n" +
            "YINGDUSHULIANG = #{yingdushuliang,jdbcType=INTEGER},\n" +
            "YINGDUSHICEZHI = #{yingdushicezhi,jdbcType=VARCHAR},\n" +
            "BEIZHU = #{beizhu,jdbcType=VARCHAR},\n" +
            "STATE = #{state,jdbcType=INTEGER},\n" +
            "MODIFY_USER = #{modifyUser,jdbcType=VARCHAR},\n" +
            "MODIFY_DATE = #{modifyDate,jdbcType=VARCHAR} \n" +
            "where objuid = #{objuid,jdbcType=VARCHAR} ")
    int update(FenguangYingduRecordDO fenguangYingduRecordDO);
}
